#include <ctime>
#include <iostream>
#include <fstream>
using namespace std;
void bubbleSort(int ma[], int maL) {
	while(maL--) 	{
		bool sw = false;
		
		for(int i = 0; i < maL; i++) {
			if(ma[i] > ma[i + 1]){
				swap(ma[i], ma[i + 1]);
				sw = true;
			}
		}	
		if(sw == false) break;
	}
}

void read_from_file(const char *filename, int a[], int length) {
    ifstream file(filename);
    for(int i=0; i < length; i++)
        file >> a[i];
}
int main()
{
    #define L 5000
    int MASIV[L];

    read_from_file("a_sorted.txt",MASIV,L);
    unsigned int st=clock();
    bubbleSort(MASIV,L);
    unsigned int fin=clock();
    unsigned int wo=fin-st;
    cout<<"a_sorted " << wo << " milliseconds \n";
    
    read_from_file("b_reverse.txt",MASIV,L);
    st=clock();
    bubbleSort(MASIV,L);
    fin=clock();
    wo=fin-st;
    cout<<"b_reverse "<<wo<<" milliseconds \n";
    
    read_from_file("c_shuffle.txt",MASIV,L);
    st=clock();
    bubbleSort(MASIV,L);
    fin=clock();
    wo=fin-st;
    cout<<"c_shuffle "<<wo<<" milliseconds \n";
    
    return 0;
}